package edu.uis.project.frankszoo.model.score;

import java.util.ArrayList;
import java.util.List;

/**
 * PlayerScore class represents the score of a player in the game. Players' score details are maintained in lists.
 */
public class PlayerScore {

	protected String playerName; // Name of the player
	protected String playerID;// ID of the player
	protected int totalScore;// Total score earned by the player in the game
	protected int playerPosition;// Overall position of the player in the game
	protected List<PlayerHandScore> handScores;// List containing PlayerHandScore for each hand in the game

	/**
	 * This is the constructor for the PlayScore
	 * 
	 * @param playerName
	 *            Name of the player
	 * @param playerID
	 *            ID of the player
	 */
	public PlayerScore(String playerName, String playerID) {
		this.playerName = playerName;
		this.playerID = playerID;
		this.handScores = new ArrayList<PlayerHandScore>();
	}

	/**
	 * This method returns the name of the player
	 * 
	 * @return playerName Name of the player
	 */
	public String getPlayerName() {
		return this.playerName;
	}

	/**
	 * This method returns the ID of the player
	 * 
	 * @return playerID ID of the player
	 */
	public String getPlayerID() {
		return this.playerID;
	}

	/**
	 * This method returns the sum of all the scores across all the hands
	 * 
	 * @return totalScore Sum of all the scores across all the hands.
	 */
	public int getTotalScore() {
		return this.totalScore;
	}

	/**
	 * This method sets the player's position in the game
	 * 
	 * @param playerPosition
	 *            The player's position in the game
	 */
	public void setPlayerPosition(int playerPosition) {
		this.playerPosition = playerPosition;
	}

	/**
	 * This method returns the player's position in the game
	 * 
	 * @return playerPosition The player's position in the game
	 */
	public int getPlayerPosition() {
		return this.playerPosition;
	}

	/**
	 * This method adds player's score in each hand in the Array list playerHandScore
	 * 
	 * @param playerHandScore
	 *            Player's score in the hand
	 */
	public void addHandScore(PlayerHandScore playerHandScore) {
		this.handScores.add(playerHandScore);
		this.totalScore += playerHandScore.individualScore;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return "" + playerName + ": Rank: " + playerPosition + ", Score:" + totalScore;
	}
}
